<?php
/**
 * @Author: kendy
 * @Date:   2020-03-16 14:22:17
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2020-04-03 09:36:56
 */

namespace app\hotel\controller; 
use Think\Db;
use think\Request;
use think\Session;
use app\admin\model\OrderRefunds as ors;
use app\hotel\model\OrderRefunds as oc; 
class OrderRefunds extends Common
{
        /**
     * [OrderComplainsList 商家投诉订单列表]
     * @Author   kendy
     * @DateTime 2019-12-18T15:52:43+0800
     */
      public function Orderrefunds()
      { 
         if (Request::instance()->isAjax()){  
             $data = input('param.'); 
             $where = [];
             if (isset($data['order_sn']) && $data['order_sn'] != '') {
                $where['oc.order_sn'] = array('like', '%' . $data['order_sn'] . '%');
            }
            if (isset($data['refund_status']) && $data['refund_status'] != '') {
                $where['refund_status'] = $data['refund_status'];
            }
            if (isset($data['create_time']) && $data['create_time'] != ''){
                $created_at=explode(' - ', $data['create_time']); 
                if (isset($created_at) && is_array($created_at)){
                    foreach($created_at as $k=>$v)
                    {
                       $created_at[$k] = strtotime($v);
                    }  
                }
              $where['oc.create_time']=['between',$created_at]; 
            } 


            $data =  model('OrderRefunds')->getOrderRefundList($where);
            $count = model('OrderRefunds')->getOrderRefundList($where,true);
            return ['code'=>0,'msg'=>'','count'=>$count,'data'=>$data]; 
        }else{ 
            $res = model('OrderRefunds')->getOrderRefundList([]);
            $this->assign('res', $res);
            return view(); 
        }
      }
  
      /**
    * [getOrderDetail 获取订单详情]
    * @Author   kendy
    * @DateTime 2019-12-23T11:04:42+0800
    * @return   [type]                   [description]
    */
   public function getorderinfo()
   {
       if (request()->isAjax()) {
           $refund = new oc();
            $postData = input('param.');
            $where = "order_id= {$postData['order_id']}"; 
            $hotelOrderInfo = $refund->getOrderInfoById($where);
            return ['code'=>0,'msg'=>'','count'=>1,'data'=>$hotelOrderInfo];  
        }
   } 

    /**
     * [orderRefund 是否同意退款]
     * @Author   kendy
     * @DateTime 2020-03-18T08:39:45+0800
     * @return   [type]                   [description]
     */
    public function refundorder(){
        if (request()->isAjax()) {
            $m = new oc();
            return $m->refundorder();  
       
     }
   }
    

 }